<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of findInDatabase
 *
 * @author 12502
 */
include_once 'linkdatabase.php';

class findInDatabase {

    public static function finduid($openId) {
        $link = linkdatabase::link();
        @mysqli_select_db($link, "witkey");
        $query = "select u_id from users where 
             open_id ='" . $openId . "'";
        $result = mysqli_query($link, $query);
        if (!$result) {
            echo 'can not run3';
            return null;
        }
        $row = mysqli_fetch_row($result);
        if (!$row) {
            $count=null;
        }else{
            $count = $row[0];
        }
        return $count;
    }

    public static function findName($uid) {
        $link = linkdatabase::link();
        @mysqli_select_db($link, "witkey");
        $query = "select * from users where 
             u_id ='".$uid."'";
        $result = mysqli_query($link, $query);
        if (!$result) {
            echo "name gg";
        } else {
            $row = mysqli_fetch_array($result);
            return $row;
        }
    }

    public static function findImage($username) {
        $link = linkdatabase::link();
        @mysqli_select_db($link, "sample");
        $query = "select * from archives where 
             stu_number ='$username' ";
        $result = mysqli_query($link, $query);
        if (!$result) {
            echo "image gg";
        } else {
            $row = mysqli_fetch_array($result);
            $image = $row['image'];
           echo $image;
        }
    }
}
?>

